<?php

//error_reporting(E_ERROR | E_WARNING | E_PARSE);
mysql_connect("localhost", "root", "root");
@mysql_select_db(faithwar) or die("Unable to select database");
set_time_limit(0);
ini_set("memory_limit", "200M");
date_default_timezone_set("PRC"); //timezone

$dateTime = date("Y-m-d",strtotime("-1 day"));
#$dateTime = date("Y-m-d");

$handle = @fopen("/var/www/log/faithwar/trunk/register/log/register.log.$dateTime", "r");
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        //echo $buffer;
        $userid= substr($buffer,30, 33);
        $deviceid =substr($buffer,63, 80);
        $createdate =substr($buffer,0, 17);
        $date =substr($buffer,0, 8);
 mysql_query("INSERT INTO register (userid,deviceid,createdate,date)
                    VALUES('$userid','$deviceid','$createdate','$date')") or die(mysql_error());
    }
    fclose($handle);
}

 mysql_query("DELETE FROM register WHERE userid =''");
 mysql_query("DELETE FROM register WHERE date ='0000-00-00'");
?>
